package wymiana.domain;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import wymiana.enumeration.FileType;

/**
 * 
 * @author Rafal Magdon
 * @version 1.0
 * 
 *          Description:
 * 
 */
@Entity
@Table(name = "uploaded_file")
public class UploadedFiles extends BaseEntity {

	/** serialization uid */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(updatable = false, name = "FILE_ID")
	private Integer idFile;

	@Column(length = 500, nullable = false)
	private String filename;

	@Column(length = 1000, nullable = false)
	private String filePath;

	@Column(length = 4000, nullable = false)
	private String fileDescription;
	
	@Column(nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date creationDate;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "createUser")
	private User createUser;

	@Column(length = 255, nullable = false)
	private String size;

	@Column
	@Enumerated(EnumType.ORDINAL)
	private FileType fileType;
	
	@ManyToOne
	@JoinColumn(name = "dgroup", nullable = true)
	private DGroup dgroup;

	// @ManyToOne(fetch = FetchType.LAZY)
	// @JoinColumn(name = "PERSON_ID")
	// private User directlyUser;

	// TODO polaczenie z grupa

	// @ManyToMany(fetch = FetchType.LAZY)
	// @JoinTable(name = "uploaded_file_genre", joinColumns = {
	// @javax.persistence.JoinColumn(name = "FILE_ID") }, inverseJoinColumns = {
	// @javax.persistence.JoinColumn(name = "GENRE_ID") })
	// private List<Genre> genre;

	public Integer getIdFile() {
		return idFile;
	}

	public void setIdFile(Integer idFile) {
		this.idFile = idFile;
	}

	public String getFilename() {
		return filename;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

	public String getFileDescription() {
		return fileDescription;
	}

	public void setFileDescription(String fileDescription) {
		this.fileDescription = fileDescription;
	}


	// public List<Genre> getGenre() {
	// return genre;
	// }
	//
	// public void setGenre(List<Genre> genre) {
	// this.genre = genre;
	// }

	/**
	 * @return the createUser
	 */
	public User getCreateUser() {
		return createUser;
	}

	/**
	 * @param createUser
	 *            the createUser to set
	 */
	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	public String getSize() {
		return size;
	}

	public void setSize(String size) {
		this.size = size;
	}

	public FileType getFileType() {
		return fileType;
	}

	public void setFileType(FileType fileType) {
		this.fileType = fileType;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public DGroup getDgroup() {
		return dgroup;
	}

	public void setDgroup(DGroup dgroup) {
		this.dgroup = dgroup;
	}

}
